package exception;

/**
 * java异常处理机制
 *
 * Throwable下面按派生两个子类
 */
public class TryCatchDemo {
    public static void main(String[] args) {
        System.out.println("程序开始了");
        try {
//            String line = "";
            String line = "abc";
            System.out.println(line.length());
            System.out.println(line.charAt(0));
            System.out.println(Integer.parseInt(line));
//        }catch (NullPointerException e){
//            System.out.println("出现了空指针异常");
//        }catch (StringIndexOutOfBoundsException e){
//            System.out.println("出现了字符串下表越界异常,并处理了");
//        }
        }catch (NullPointerException|StringIndexOutOfBoundsException e){
            System.out.println("出现了空指针异常或下表越界异常");
        }catch (Exception e){
            System.out.println("欸欸欸!!!看看这嘎达,这里出错了,你瞅瞅咋了" );
        }

        System.out.println("程序结束了");
    }
}
